using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace Impact.Model.Objects{
    /// <summary>
    /// Strongly-typed collection for the ArticleTag class.
    /// </summary>
    [Serializable]
    public partial class ArticleTagCollection : ReadOnlyList<ArticleTag, ArticleTagCollection>
    {        
        public ArticleTagCollection() {}
    }
    /// <summary>
    /// This is  Read-only wrapper class for the vw_impact_ArticleTags view.
    /// </summary>
    [Serializable]
    public partial class ArticleTag : ReadOnlyRecord<ArticleTag>, IReadOnlyRecord
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }
	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }
                return BaseSchema;
            }
        }
    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("vw_impact_ArticleTags", TableType.View, DataService.GetInstance("ImpactProvider"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = @"dbo";
                //columns
                
                TableSchema.TableColumn colvarArticleTagId = new TableSchema.TableColumn(schema);
                colvarArticleTagId.ColumnName = "ArticleTagId";
                colvarArticleTagId.DataType = DbType.Int32;
                colvarArticleTagId.MaxLength = 0;
                colvarArticleTagId.AutoIncrement = false;
                colvarArticleTagId.IsNullable = false;
                colvarArticleTagId.IsPrimaryKey = false;
                colvarArticleTagId.IsForeignKey = false;
                colvarArticleTagId.IsReadOnly = false;
                
                schema.Columns.Add(colvarArticleTagId);
                
                TableSchema.TableColumn colvarArticleId = new TableSchema.TableColumn(schema);
                colvarArticleId.ColumnName = "ArticleId";
                colvarArticleId.DataType = DbType.Int32;
                colvarArticleId.MaxLength = 0;
                colvarArticleId.AutoIncrement = false;
                colvarArticleId.IsNullable = false;
                colvarArticleId.IsPrimaryKey = false;
                colvarArticleId.IsForeignKey = false;
                colvarArticleId.IsReadOnly = false;
                
                schema.Columns.Add(colvarArticleId);
                
                TableSchema.TableColumn colvarTagId = new TableSchema.TableColumn(schema);
                colvarTagId.ColumnName = "TagId";
                colvarTagId.DataType = DbType.Int32;
                colvarTagId.MaxLength = 0;
                colvarTagId.AutoIncrement = false;
                colvarTagId.IsNullable = false;
                colvarTagId.IsPrimaryKey = false;
                colvarTagId.IsForeignKey = false;
                colvarTagId.IsReadOnly = false;
                
                schema.Columns.Add(colvarTagId);
                
                TableSchema.TableColumn colvarTextX = new TableSchema.TableColumn(schema);
                colvarTextX.ColumnName = "Text";
                colvarTextX.DataType = DbType.AnsiString;
                colvarTextX.MaxLength = 50;
                colvarTextX.AutoIncrement = false;
                colvarTextX.IsNullable = false;
                colvarTextX.IsPrimaryKey = false;
                colvarTextX.IsForeignKey = false;
                colvarTextX.IsReadOnly = false;
                
                schema.Columns.Add(colvarTextX);
                
                TableSchema.TableColumn colvarCreatedBy = new TableSchema.TableColumn(schema);
                colvarCreatedBy.ColumnName = "CreatedBy";
                colvarCreatedBy.DataType = DbType.String;
                colvarCreatedBy.MaxLength = 50;
                colvarCreatedBy.AutoIncrement = false;
                colvarCreatedBy.IsNullable = false;
                colvarCreatedBy.IsPrimaryKey = false;
                colvarCreatedBy.IsForeignKey = false;
                colvarCreatedBy.IsReadOnly = false;
                
                schema.Columns.Add(colvarCreatedBy);
                
                TableSchema.TableColumn colvarCreatedOn = new TableSchema.TableColumn(schema);
                colvarCreatedOn.ColumnName = "CreatedOn";
                colvarCreatedOn.DataType = DbType.DateTime;
                colvarCreatedOn.MaxLength = 0;
                colvarCreatedOn.AutoIncrement = false;
                colvarCreatedOn.IsNullable = false;
                colvarCreatedOn.IsPrimaryKey = false;
                colvarCreatedOn.IsForeignKey = false;
                colvarCreatedOn.IsReadOnly = false;
                
                schema.Columns.Add(colvarCreatedOn);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["ImpactProvider"].AddSchema("vw_impact_ArticleTags",schema);
            }
        }
        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }
	    #endregion
	    
	    #region .ctors
	    public ArticleTag()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }
        public ArticleTag(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}
			MarkNew();
	    }
	    
	    public ArticleTag(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }
    	 
	    public ArticleTag(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }
        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("ArticleTagId")]
        [Bindable(true)]
        public int ArticleTagId 
	    {
		    get
		    {
			    return GetColumnValue<int>("ArticleTagId");
		    }
            set 
		    {
			    SetColumnValue("ArticleTagId", value);
            }
        }
	      
        [XmlAttribute("ArticleId")]
        [Bindable(true)]
        public int ArticleId 
	    {
		    get
		    {
			    return GetColumnValue<int>("ArticleId");
		    }
            set 
		    {
			    SetColumnValue("ArticleId", value);
            }
        }
	      
        [XmlAttribute("TagId")]
        [Bindable(true)]
        public int TagId 
	    {
		    get
		    {
			    return GetColumnValue<int>("TagId");
		    }
            set 
		    {
			    SetColumnValue("TagId", value);
            }
        }
	      
        [XmlAttribute("Text")]
        [Bindable(true)]
        public string Text 
	    {
		    get
		    {
			    return GetColumnValue<string>("Text");
		    }
            set 
		    {
			    SetColumnValue("Text", value);
            }
        }
	      
        [XmlAttribute("CreatedBy")]
        [Bindable(true)]
        public string CreatedBy 
	    {
		    get
		    {
			    return GetColumnValue<string>("CreatedBy");
		    }
            set 
		    {
			    SetColumnValue("CreatedBy", value);
            }
        }
	      
        [XmlAttribute("CreatedOn")]
        [Bindable(true)]
        public DateTime CreatedOn 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("CreatedOn");
		    }
            set 
		    {
			    SetColumnValue("CreatedOn", value);
            }
        }
	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string ArticleTagId = @"ArticleTagId";
            
            public static string ArticleId = @"ArticleId";
            
            public static string TagId = @"TagId";
            
            public static string Text = @"Text";
            
            public static string CreatedBy = @"CreatedBy";
            
            public static string CreatedOn = @"CreatedOn";
            
	    }
	    #endregion
	    
	    
	    #region IAbstractRecord Members
        public new CT GetColumnValue<CT>(string columnName) {
            return base.GetColumnValue<CT>(columnName);
        }
        public object GetColumnValue(string columnName) {
            return base.GetColumnValue<object>(columnName);
        }
        #endregion
	    
    }
}
